//
//  YellowBtn.m
//  hitTest
//
//  Created by Yanyan Jiang on 2021/9/4.
//

#import "YellowBtn.h"

@implementation YellowBtn

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
    NSLog(@"%s",__func__);
    CGPoint accessP =  [self  convertPoint:point toView:self.accessBtn];
    if ([self.accessBtn pointInside:accessP withEvent:event]) {
        return self.accessBtn;
    }
    return [super hitTest:point withEvent:event];
}

- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    UITouch *touch = [touches anyObject];
    CGPoint pointP = [touch previousLocationInView:self];
    CGPoint currentP = [touch locationInView:self];
    
    CGFloat tx = currentP.x- pointP.x;
    CGFloat ty = currentP.y- pointP.y;
    self.transform = CGAffineTransformTranslate(self.transform, tx, ty);
}

@end
